<?php
/**
 * Manageaccount_Model_Updateuserdata
 * update user data
 *
 * @author Adrian Stolarski
 */
class Manageaccount_Model_Updateuserdata implements Manageaccount_Model_Mainable, 
        Manageaccount_Model_Checkoutable, Manageaccount_Model_Setable, 
        Manageaccount_Model_Redirectable {
    /**
     *
     * @var type $check_user_data
     * check user data handler
     */
    public $check_user_data;
    /**
     *
     * @var type $redirect_handler
     * redirect handler
     */
    public $redirect_handler;
    /**
     *
     * @var type $set_data
     * set data handler
     */
    public $set_data;
    
    public function main(array $variables = null) {
        //var_dump($variables);
        //print_r(-sessI$variables['user_id']);
        //var_dump($_SESSION);
        //var_dump($variables);
        //die();
        $this->check_data($variables);
        $this->set_data($variables);
    }
    
    /**
     * check_data()
     * check user data
     * 
     * @param array $variables
     */
    public function check_data(array $variables = null) {
        //var_dump($variables);
        //die();
        $this->check_user_data = new Manageaccount_Data_Checkuserdata;
        $user_data = $this->check_user_data->main($variables);
        if($_SESSION['user_id'] != $user_data['id']){
            $this->redirect_action($variables);
        }
        //var_dump($user_data);
        //die();
    }
    /**
     * set_data()
     * update user data
     * @param array $variables
     */
    public function set_data(array $variables = null) {
        $this->set_data = new Manageaccount_Data_Updateuserdata;
        $this->set_data->main($variables);
        //var_dump($variables);
        //die();
        $this->redirect_action($variables);
    }
    
    /**
     * redirect_action()
     * redirect action implementation
     * @param array $variables
     */
    public function redirect_action(array $variables = null) {
        $this->redirect_handler = new Manageaccount_Data_Redirectmanageaccount;
        $this->redirect_handler->main($variables);
    }

}
